<?php
declare (strict_types = 1);

namespace app\controller\admin;

use think\response\Json;

class AdminHome extends AdminBase
{

	protected $middleware = [
        'app\middleware\AdminLogin',
		//'app\middleware\AdminAuth' => ['except' => ['chart'] ]
	];

	private string $menuName = '首页';

    /**
     * 显示资源列表
     * @throws
     * @return Json
     */
    public function index():Json
    {
        //测试数据
		$this->result['data'] = [
            [
            'num1' => '125,12',
			'num2' => '-12.32%',
			'num3' => '订单统计信息',
			'num4' => 'fa fa-meetup',
			'color1' => '#FF6462',
			'color2' => '--next-color-primary-lighter',
			'color3' => '--el-color-primary',
            ],
            [
                'num1' => '653,33',
                'num2' => '+42.32%',
                'num3' => '月度计划信息',
                'num4' => 'iconfont icon-ditu',
                'color1' => '#6690F9',
                'color2' => '--next-color-success-lighter',
                'color3' => '--el-color-success',
            ],
            [
                'num1' => '125,65',
                'num2' => '+17.32%',
                'num3' => '年度计划信息',
                'num4' => 'iconfont icon-zaosheng',
                'color1' => '#6690F9',
                'color2' => '--next-color-warning-lighter',
                'color3' => '--el-color-warning',
            ],
            [
                'num1' => '520,43',
                'num2' => '-10.01‰',
                'num3' => '访问统计信息',
                'num4' => 'fa fa-github-alt',
                'color1' => '#FF6462',
                'color2' => '--next-color-danger-lighter',
                'color3' => '--el-color-danger',
            ]
        ];
		return jJson($this->result);
    }

    /**
     * 显示资源列表
     * @throws
     * @return Json
     */
    public function chart():Json
    {


        //测试数据
        $this->result['data'] = [
            'lineChart'=> [
                'name' => ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
                'data' => [0, 24.1, 7.2, 15.5, 42.4, 42.4, 42.4, 24.1, 7.2, 15.5, 42.4, 0]
            ],
            'pieChart' => [
                'name' => ['房屋及结构物', '专用设备', '通用设备', '文物和陈列品', '图书、档案'],
                'data' => [
                    [ 'name' => '房屋及结构物', 'value' => 34.2 ],
                    [ 'name' => '专用设备', 'value' => 38.87 ],
                    [ 'name' => '通用设备', 'value' => 17.88 ],
                    [ 'name' => '文物和陈列品', 'value' => 9.05 ],
                    [ 'name' => '图书、档案', 'value' => 2.05 ],
                ]
            ],
            'barChart' => [
                'gw' => [
                    [ 'value' => 1, 'stationName' => 's1' ],
                    [ 'value' => 3, 'stationName' => 's2' ],
                    [ 'value' => 4, 'stationName' => 's3' ],
                    [ 'value' => 9, 'stationName' => 's4' ],
                    [ 'value' => 3, 'stationName' => 's5' ],
                    [ 'value' => 2, 'stationName' => 's6' ],
                ],
                'hw' => [
                    [ 'value' => 31, 'stationName' => 's1' ],
                    [ 'value' => 36, 'stationName' => 's2' ],
                    [ 'value' => 54, 'stationName' => 's3' ],
                    [ 'value' => 24, 'stationName' => 's4' ],
                    [ 'value' => 73, 'stationName' => 's5' ],
                    [ 'value' => 22, 'stationName' => 's6' ],
                ],
                'yl' => [
                    [ 'value' => 11, 'stationName' => 's1' ],
                    [ 'value' => 34, 'stationName' => 's2' ],
                    [ 'value' => 54, 'stationName' => 's3' ],
                    [ 'value' => 39, 'stationName' => 's4' ],
                    [ 'value' => 63, 'stationName' => 's5' ],
                    [ 'value' => 24, 'stationName' => 's6' ],
                ]
            ]
        ];
        return jJson($this->result);
    }

}
